package com.bussiness.system.controller;

import java.util.Arrays;
import java.util.Map;


import com.bussiness.system.entity.SysDictEntity;
import com.bussiness.system.query.sys.SsSysDictQuery;
import com.bussiness.system.util.Result;
import com.bussiness.system.api.SysDictControllerApi;
import com.bussiness.system.face.SysDictService;
import com.bussiness.system.fegin.UserService;
import com.bussiness.system.form.SysDictForm;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * 数据字典表
 *
 * @author xlr
 * @email liru@tengyue360
 * @date 2018-08-11 19:26:41
 */
@RestController
public class SysDictController implements SysDictControllerApi {

    @Autowired
    private SysDictService ssSysDictService;

    @Override
    public Result test(Integer id) {
        return null;
    }

    /**
     * 列表
     */
    public Result listS( @RequestParam SsSysDictQuery query){
        return null;
    }


    /**
     * 信息
     */
    public Result info(@PathVariable("id") Long id){
        SysDictEntity ssSysDict = ssSysDictService.selectById(id);

        return new Result<SysDictEntity>().success(ssSysDict);
    }

    /**
     * 保存
     */
    public Result save(@RequestBody SysDictForm query){
        SysDictEntity ssSysDict = new SysDictEntity();
        BeanUtils.copyProperties(query,ssSysDict);
        ssSysDictService.insert(ssSysDict);
        return new Result<>().success();
    }

    /**
     * 修改
     */

    public Result update(@RequestBody SsSysDictQuery query){
        SysDictEntity ssSysDict = new SysDictEntity();
        BeanUtils.copyProperties(query,ssSysDict);
        ssSysDictService.updateAllColumnById(ssSysDict);//全部更新
        return new Result<>().success();
    }

    /**
     * 删除
     */
    public Result delete(@RequestBody Long[] ids){
        ssSysDictService.deleteBatchIds(Arrays.asList(ids));
        return new Result<>().success();
    }

}
